﻿using B.S.BasicData.Domain.SystemUsers;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Write.Api.Application.Command.SystemUsers.IAMCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class IAMController : ControllerBase
    {
        private readonly IMediator mediator;

        public IAMController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 身份校验添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddIAM(IAMAddCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }

        /// <summary>
        /// 显示身份校验列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<IAM_Model>> ShowIAM([FromQuery]IAMShowPageCommand request, CancellationToken cancellationToken) 
        {
            return mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 删除身份校验列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpDelete]
        public Task<ApiResult<int>> DelIam(IAMDelCommand request, CancellationToken cancellationToken) 
        {
        return mediator.Send(request, cancellationToken);
        }


        /// <summary>
        /// 编辑身份校验管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateIAM(IAMUpdateCommand request, CancellationToken cancellationToken) 
        {
            return mediator.Send(request, cancellationToken);
        }

        /// <summary>
        /// 获取身份校验管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<IAM_Model>> GetIAM([FromQuery]IAMGetCommand request, CancellationToken cancellationToken) 
        {
            return mediator.Send(request, cancellationToken);
        }
    }
}
